    $(function() {
        $('.checkall').change(function() {
            $('.j-checkbox,.checkall').prop('checked', $(this).prop('checked'));
            if ($(this).prop('checked')) {
                $('.j-checkbox').parents('.cart-item').each(function() {
                    $(this).addClass('check-cart-item');
                })
            } else {
                $('.j-checkbox').parents('.cart-item').each(function() {
                    $(this).removeClass('check-cart-item');
                })
            }
        });
        $('.j-checkbox').change(function() {
            if ($('.j-checkbox:checked').length == $('.j-checkbox').length) {
                $('.checkall').prop('checked', true);
            } else {
                $('.checkall').prop('checked', false);
            }
            if ($(this).prop('checked')) {
                $(this).parents('.cart-item').addClass('check-cart-item');
            } else {
                $(this).parents('.cart-item').removeClass('check-cart-item');
            }
        })
        let pNumber = $('.p-num');
        let decrement = pNumber.find('.decrement');
        let increment = pNumber.find('.increment');
        decrement.click(function() {
            let number = $(this).siblings('input').val();
            let pPrice = $(this).parents('.p-num').siblings('.p-price');
            let one = pPrice.text().substr(1);
            number = number == 1 ? 1 : number - 1;
            let pSum = pPrice.siblings('.p-sum');
            pSum.text('￥' + (one * number).toFixed(2));
            $(this).siblings('input').val(number);
            cheackNumber();
        })
        increment.click(function() {
            let pPrice = $(this).parents('.p-num').siblings('.p-price');
            let one = pPrice.text().substr(1);
            let number = parseInt($(this).siblings('input').val());
            number = number == 99 ? 99 : number + 1;
            let pSum = pPrice.siblings('.p-sum');
            pSum.text('￥' + (one * number).toFixed(2));
            $(this).siblings('input').val(number);
            cheackNumber();
        })

        $('.itxt').change(function() {
            let number = $(this).val();
            if (number > 99) {
                number = 99;
            } else if (number <= 0) {
                number = 1;
            }
            $(this).val(number)
            let pPrice = $(this).parents('.p-num').siblings('.p-price');
            let one = pPrice.text().substr(1);
            let pSum = pPrice.siblings('.p-sum');
            pSum.text('￥' + (one * number).toFixed(2));
            cheackNumber();
        })


        let cheackNumber = function() {
            let itxts = $('.itxt');
            let pSum = $('.p-sum');
            let numberSum = 0;
            let sum = 0;
            itxts.each(function(i, e) {
                numberSum += parseInt($(e).val());
            })
            pSum.each(function(i, e) {
                sum += parseFloat($(e).text().substr(1));
            })
            let amountSum = $('.amount-sum');
            let priceSum = $('.price-sum');
            amountSum.children('em').text(numberSum);
            priceSum.children('em').text('￥' + sum.toFixed(2));
        }
        cheackNumber();

        let pAction = $('.p-action');
        pAction.click(function() {
            $(this).parents('.cart-item').remove();
            cheackNumber();
        })

        let removeBatch = $('.remove-batch');
        removeBatch.click(function() {
            $('.j-checkbox:checked').each(function() {
                $(this).parent().siblings('.p-action').click();
            })
        })

        let clearAll = $('.clear-all');
        clearAll.click(function() {
            $('.cart-item-list').empty();
            cheackNumber();
        })
    })